import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:json_theme/json_theme.dart';

class AppTheme {
  static final shared = AppTheme._();
  AppTheme._();

  late final ThemeData currentTheme;

  Color get inputTextFieldBackgroundColor => Colors.grey[100]!;

  Color get appBarSearchTextTipColor => Colors.grey[500]!;

  Color get commonTipColor => Colors.orange;

  Color get greyColor => Colors.grey[500]!;

  Color get whiteColor => Colors.white;

  Color get purchaseTipColor => Colors.red;

  bool get isDark => currentTheme.brightness == Brightness.dark;

  Future<void> init() async {
    final themeString = await rootBundle.loadString(
      'assets/jsons/advanced_theme.json',
    );
    final themeJson = jsonDecode(themeString);
    currentTheme = ThemeDecoder.decodeThemeData(themeJson)!;
  }
}
